<?php
namespace Yzadmin\Controller;
use Think\Controller;
class UploadController extends CkController
{
   //后台首页
   public function index()
   {
      p(I("get."));
   }
   
   //图片上传
   public function images()
   { 
    $upload = new \Think\Upload();// 实例化上传类
    $upload->maxSize   =     3145728 ;// 设置附件上传大小
    $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
    $upload->rootPath  =      './Uploads/images/'; // 设置附件上传根目录
    $upload->savePath  =     ''; // 设置附件上传（子）目录
    // 上传文件 
    $info   =  $upload->upload();
     if(!$info) {// 上传错误提示错误信息
       exit(json_encode(array('error' => 1, 'message' => $upload->getError())));
    }else{// 上传成功 获取上传文件信息
      if($info['file']){
         $url=  "/Uploads/images/".$info["file"]['savepath'].$info["file"]['savename'];
      }else{
        $url= "/Uploads/images/".$info["imgFile"]['savepath'].$info["imgFile"]['savename'];
      }
      exit( json_encode(array('error'=>0,'url'=>__ROOT__.$url)));
    }
   }

   
   //图片浏览
   public function file_manager()
   {
     die("12");
   } 

}